<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Returns namespaces used in document</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="simplexmlelement.getname.html">SimpleXMLElement::getName</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="simplexmlelement.registerxpathnamespace.html">SimpleXMLElement::registerXPathNamespace</a></div>
 <div class="up"><a href="class.simplexmlelement.html">SimpleXMLElement</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="simplexmlelement.getnamespaces" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">SimpleXMLElement::getNamespaces</h1>
  <p class="verinfo">(PHP 5 &gt;= 5.1.2)</p><p class="refpurpose"><span class="refname">SimpleXMLElement::getNamespaces</span> &mdash; <span class="dc-title">
   Returns namespaces used in document
  </span></p>

 </div>
 <div class="refsect1 description" id="refsect1-simplexmlelement.getnamespaces-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="type">array</span> <span class="methodname"><strong>SimpleXMLElement::getNamespaces</strong></span>
    ([ <span class="methodparam"><span class="type">bool</span> <code class="parameter">$recursive</code><span class="initializer"> = false</span></span>
  ] )</div>

  <p class="para rdfs-comment">
   Returns namespaces used in document
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-simplexmlelement.getnamespaces-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>

    
     <dt>
<em><code class="parameter">recursive</code></em></dt>

     <dd>

      <p class="para">
       If specified, returns all namespaces used in parent and child nodes. 
       Otherwise, returns only namespaces used in root node.
      </p>
     </dd>

    
   </dl>

  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-simplexmlelement.getnamespaces-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   The <em>getNamespaces</em> method returns an <span class="type"><a href="language.types.array.html" class="type array">array</a></span> of 
   namespace names with their associated URIs.
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-simplexmlelement.getnamespaces-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="example-5390">
    <p><strong>Example #1 Get document namespaces in use</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /><br />$xml&nbsp;</span><span style="color: #007700">=&nbsp;&lt;&lt;&lt;XML<br /></span><span style="color: #DD0000">&lt;?xml&nbsp;version="1.0"&nbsp;standalone="yes"?&gt;<br />&lt;people&nbsp;xmlns:p="http://example.org/ns"&nbsp;xmlns:t="http://example.org/test"&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&lt;p:person&nbsp;id="1"&gt;John&nbsp;Doe&lt;/p:person&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&lt;p:person&nbsp;id="2"&gt;Susie&nbsp;Q.&nbsp;Public&lt;/p:person&gt;<br />&lt;/people&gt;<br /></span><span style="color: #007700">XML;<br />&nbsp;<br /></span><span style="color: #0000BB">$sxe&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">SimpleXMLElement</span><span style="color: #007700">(</span><span style="color: #0000BB">$xml</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">$namespaces&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$sxe</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getNamespaces</span><span style="color: #007700">(</span><span style="color: #0000BB">true</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$namespaces</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

    <div class="example-contents"><p>以上例程会输出：</p></div>
    <div class="example-contents screen">
<div class="cdata"><pre>
array(1) {
  [&quot;p&quot;]=&gt;
  string(21) &quot;http://example.org/ns&quot;
}
</pre></div>
    </div>
   </div>
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-simplexmlelement.getnamespaces-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><span class="methodname"><a href="simplexmlelement.getdocnamespaces.html" class="methodname" rel="rdfs-seeAlso">SimpleXMLElement::getDocNamespaces()</a> - Returns namespaces declared in document</span></li>
    <li class="member"><span class="methodname"><a href="simplexmlelement.registerxpathnamespace.html" class="methodname" rel="rdfs-seeAlso">SimpleXMLElement::registerXPathNamespace()</a> - Creates a prefix/ns context for the next XPath query</span></li>
   </ul>
  </p>
 </div>

</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="simplexmlelement.getname.html">SimpleXMLElement::getName</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="simplexmlelement.registerxpathnamespace.html">SimpleXMLElement::registerXPathNamespace</a></div>
 <div class="up"><a href="class.simplexmlelement.html">SimpleXMLElement</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>
